#region Microsoft Public License
/*
 * (c) Copyright Chenjun Wu. http://utablesdk.codeplex.com
 * 
 * This source is subject to the Microsoft Public License (Ms-PL).
 * Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
 * All other rights reserved.
 */
#endregion

﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UTable.Objects
{
    public class UAlbumPreview: UObjectPreview
    {
        protected UAlbumModel Model;

        public override object GetModel()
        {
            return this.Model.Clone();
        }

        public override void UpdateModel(object updateMessage)
        {
            if (updateMessage is SetFolderPathMessage)
            {
                this.Model.FolderPath = (updateMessage as SetFolderPathMessage).FolderPath;
                this.FolderPath = Model.FolderPath;
            }
            else if (updateMessage is ChangeAlbumBrowseModeMessage)
            {
                this.Model.BrowseMode = (updateMessage as ChangeAlbumBrowseModeMessage).BrowseMode;
            }
        }

        public override void InitializeModel(object model)
        {
            UAlbumModel source = model as UAlbumModel;
            if (source != null)
            {
                this.Model = new UAlbumModel(source);
                this.FolderPath = source.FolderPath;
            }
        }
    }
}
